<?php
/**
 * @package Bastard of Young
 * @version 1.0
 */
/*
Plugin Name: Bastards of Young
Plugin URI: http://benjamin-smith.com/code
Description: This is not just a plugin, it symbolizes the hopelessness and desperation of an entire generation summed up in three words sung most famously by Paul Westerberg: Bastards of Young. When activated you will randomly see a lyric from <cite>Bastards of Young</cite> in the upper right of your admin screen on every page.
Author: Lyrics changed by Benjamin Smith (actual code by Matt Mullenweg)
Version: 1.0
Author URI: http://benjamin-smith.com
*/

function bastards_of_young_get_lyric() {
	/** These are the lyrics to Bastards of Young */
	$lyrics = "God, what a mess, on the ladder of success   
Where you take one step and miss the whole first rung              
Dreams unfulfilled, graduate unskilled         
It beats pickin' cotton and waitin' to be forgotten
We are the sons of no one, bastards of young
We are the sons of no one, bastards of young       
The daughters and the sons
Clean your baby womb, trash that baby boom
Elvis in the ground, there'll ain't no beer tonight
Income tax deduction, what a hell of a function 
It beats pickin' cotton and waitin' to be forgotten
We are the sons of no one, bastards of young
We are the sons of no one, bastards of young
The daughters and the sons
Unwillingness it claim us, ya got no wars to name us
The ones who love us best are the ones we'll lay to rest
And visit their graves on holidays at best           
The ones who love us least are the ones we'll die to please
If it's any consolation, I don't begin to understand them
We are the sons of no one, bastards of young
We are the sons of no one, bastards of young
The daughters and the sons
Young...take it, it's yours...";

	// Here we split it into lines
	$lyrics = explode( "\n", $lyrics );

	// And then randomly choose a line
	return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
}

// This just echoes the chosen line, we'll position it later
function bastard() {
	$chosen = bastards_of_young_get_lyric();
	echo "<p id='bastard'>$chosen</p>";
}

// Now we set that function up to execute when the admin_notices action is called
add_action( 'admin_notices', 'bastard' );

// We need some CSS to position the paragraph
function bastard_css() {
	// This makes sure that the positioning is also good for right-to-left languages
	$x = is_rtl() ? 'left' : 'right';

	echo "
	<style type='text/css'>
	#bastard {
		float: $x;
		padding-$x: 15px;
		padding-top: 5px;		
		margin: 0;
		font-size: 11px;
	}
	</style>
	";
}

add_action( 'admin_head', 'bastard_css' );

?>
